Python Fix Object of type ‘date’ is not JSON serializable

Table of Contents

Python Fix Object of type 'date' is not JSON serializable

image

My quick & dirty JSON dump that eats dates and everything:

json.dumps(my_dictionary, indent=4, sort_keys=True, default=str)

default is a function applied to objects that aren't serializable.\
In this case it's str, so it just converts everything it doesn't know to strings. Which is great for serialization but not so great when deserializing (hence the "quick & dirty") as anything might have been string-ified without warning, e.g. a function or numpy array.

image


https://stackoverflow.com/questions/11875770/how-to-overcome-datetime-datetime-not-json-serializable

Leave a Reply

Your email address will not be published. Required fields are marked *